using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DreamBuilder.DictionaryAccess;



namespace DreamBuilder.UI.UserControls
{
    public class ControlCommon
    {
        public static string GetDataFormatType(FieldDicInfo fieldDicInfo)
        {
            switch (fieldDicInfo.FieldType)
            {
                case FIELDTYPE.TYPE_Integer:
                case FIELDTYPE.TYPE_Float:
                case FIELDTYPE.TYPE_Decimal:
                    return "{0:N" + fieldDicInfo.DecimalLength.ToString() + "}";
                case FIELDTYPE.TYPE_Date:
                    return "{0:yyyy-MM-dd}";
                default:
                    return "";
            }
        }

        public static string FormatData(FieldDicInfo fieldDicInfo,string data)
        {
            switch (fieldDicInfo.FieldType)
            {
                case FIELDTYPE.TYPE_Integer:
                case FIELDTYPE.TYPE_Float:
                case FIELDTYPE.TYPE_Decimal:
                    return decimal.Parse(data).ToString("N" + fieldDicInfo.DecimalLength.ToString() + "");
                case FIELDTYPE.TYPE_Date:
                    return System.DateTime.Parse(data).ToString("yyyy-MM-dd");
                default:
                    return "";
            }
        }

        public static HorizontalAlign GetAlignStyle(ARRANGETYPE arrangeType)
        {
            switch (arrangeType)
            {
                case ARRANGETYPE.TYPE_LeftArrange:
                    return HorizontalAlign.Left;
                case ARRANGETYPE.TYPE_MiddleArrange:
                    return HorizontalAlign.Center;
                case ARRANGETYPE.TYPE_RightArrange:
                    return HorizontalAlign.Right;
                default:
                    return HorizontalAlign.Center;
            }

        }

        public static string ConvertNumberSeparatorToServerDBFormat(string sValue)
        {
            return sValue.Replace(",", "").Replace(" ", "");
        }
    }
}
